import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;

public class abbreviations_Test {
    public boolean equals(Object obj) {
        if()
        {

        }
    }
    public static void main(String[] args) {
        PrintWriter outputStream = null;
        Scanner inputStream1 = null;
        Scanner inputStream2 = null;
        //文件存放位置
        String fileName1 = "C:\\Users\\alex\\IdeaProjects\\lesson10\\src\\mydoc\\abbreviations.txt";
        String fileName2 = "C:\\Users\\alex\\IdeaProjects\\lesson10\\src\\mydoc\\give.txt";
        String[] temp = new String[100];
        String[] replace = new String[100];
        String[] get=new String[100];

        //判别文件是否错误
        try {
            inputStream1 = new Scanner(new File(fileName1));
            inputStream2 = new Scanner(new File(fileName2));
            outputStream = new PrintWriter(fileName2);
        } catch (FileNotFoundException e) {
            System.out.println("有错但我也不知道哪里错");
            System.exit(0);
        }

        //将文件内容存入数组中
        int start = 0;
        while (inputStream1.hasNextLine()) {
            temp[start] = inputStream1.nextLine();
            replace[start] = "<"+temp[start]+">";
            start++;
            //加入括号
        }


        //测试模块
        System.out.print("enter:");
        Scanner scanner =new Scanner(System.in);
        String line =scanner.nextLine();
        //测试模块
        System.out.println(line);

        //将字符串分割放入另一个数组
//        String line = "";
//        while (inputStream2.hasNextLine()) {
//             line = inputStream2.nextLine();
//
//        }

//        //测试模块
//        for(int i = 0; i < start; i++)
//        {
//            System.out.println(temp[i]);
//            System.out.println(replace[i]);
//        }

        String ary[] = line.split(" ");

//        for(int i=0;i<ary.length;i++)
//        {
//            System.out.println(ary[i]+" ");
//        }

        //一个个比较然后交换
        for (int i = 0; i < ary.length; i++) {
            for (int j = 0; j < start; j++) {
                if (ary[i].equals(temp[j])) {
                    ary[i] = replace[j];
                }
            }
        }


        //连起来
        String result="";
        if(ary.length >1) {
            result = ary[0];
        }

        for (int i = 1; i < ary.length; i++) {
            result = result+" "+ary[i] ;
        }


        //outputStream.println(result);
        System.out.println();
        System.out.println(result);


        //关闭所有文件流
        inputStream1.close();
        inputStream2.close();
        outputStream.close();


    }
}
